using System.Collections;
using UnityEngine;

public class PreloadParticles : MonoBehaviour
{
	public string namePref = string.Empty;

	private void Awake()
	{
		if (QualityController.SfxSoundAndParticle)
		{
			StartCoroutine(LoadParticl());
		}
	}

	private void OnDestroy()
	{
		StopCoroutine(LoadParticl());
	}

	private IEnumerator LoadParticl()
	{
		ResourceRequest loadAsset = Resources.LoadAsync("Particles/Preload/" + namePref);
		while (!loadAsset.isDone)
		{
			yield return null;
		}
		if (loadAsset.asset != null)
		{
			GameObject preloadObj = Object.Instantiate(loadAsset.asset, base.transform.position, base.transform.rotation) as GameObject;
			if (preloadObj != null)
			{
				preloadObj.transform.parent = base.transform;
			}
		}
	}
}
